package io.renren.modules.job.task;

import io.renren.common.utils.DateUtil;
import io.renren.common.utils.DateUtils;
import io.renren.common.utils.SmsUtil;
import io.renren.modules.project.service.ProjectManageService;
import io.renren.modules.project.service.RenProjectService;
import io.renren.modules.project.vo.ProjectVoEntity;
import io.renren.modules.ren.entity.RenRecordEntity;
import io.renren.modules.sys.entity.SysUserEntity;
import io.renren.modules.sys.service.SysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

@Component("outputTask")
public class OutputTask {

    @Autowired
    private ProjectManageService projectManageService;

    @Autowired
    private SysUserService sysUserService;

    private Logger logger = LoggerFactory.getLogger(getClass());

    public void run(String params) {
        SysUserEntity userEntity = sysUserService.queryByUserAccount(params);
        List<ProjectVoEntity> list = projectManageService.getIsOutputList();

        String date = DateUtils.format(new Date());
        String year = date.split("-")[0];
        String month = date.split("-")[1];

        SmsUtil.sendOutputMsg(userEntity.getPhonenumber(), new String[]{year+ "-" + month,String.valueOf(list.size())});
    }
}
